#include <iostream>
#include <cstring>
using namespace std;
char pre[1000];
char in[1000];
void dfs(int prel,int prer,int inl,int inr)
{
    int i;
    if(prel>prer)
    {
        return;
    }
    char ch=pre[prel];
    for(i=inl;i<=inr;i++)
    {
        if(ch==in[i])
            break;
    }
    int lenthl=i-inl;
    dfs(prel+1,prel+lenthl,inl,lenthl+inl-1);
    dfs(prel+lenthl+1,prer,lenthl+1+inl,inr);
    cout<<in[i];
}
int main()
{
    cin>>(pre+1)>>(in+1);
    dfs(1,strlen(pre+1),1,strlen(in+1));
}
